package com.eric.text;

import java.lang.reflect.InvocationTargetException;

public class SimpleTextFactory implements TextFactory {

	private Object input;

	public SimpleTextFactory(Object input) {
		this.input = input;
	}

	public AbstractTextWorker createTextWorker(String workerType) {
		try {
			AbstractTextWorker atw = (AbstractTextWorker) Class.forName(workerType).getConstructors()[0]
					.newInstance(input);
			return atw;
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		}

		return null;
	}

}